<?php
include 'htmlLib.php';
function WebStart($title){
session_start();

print '
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strick//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>'.$title.'</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">	
<link rel="stylesheet" type="text/css" href="styles.css">
<style type = "text/css">
</style>   
</head> 
<body>
<div id="header">
<table cellspacing="0" cellpadding="0" align="center" width="100%">
<tr>
	<td class="banner"><a href="./index.php"><FONT SIZE="7" COLOR="white"><B>Adelaide CS Forum</B></FONT></a></td>
	<td class="banner" align="right"> </td>
</tr>
</table>
<div class = "backBanner"  >
	<div class="subBanner" colspan="2">&raquo;
';
if(checkLogin()){
print "Welcome ";
print '<a href="user.php?H_name=bank">'.getUserName(). '</a> | ';
print '<a href="logout.php">Logout</a>';
}else{
print'	<!--mb-->Welcome Guest <a href="login.php">Login</a> &nbsp;<a href="register.php"><b>Sign Up</b></a><!--mbend-->';
}
		print'
		| <a href="hack.php?H_name=Service">Service</a>

		| <a href="hack.php?H_name=invite">Invite Register</a>

		| <a href="faq.php">Help</a>

	</div>
</div>
<div id="showmenu" style="z-index:100;display:none;"></div>
<div id="menu_hack" class="menu" style="display:none;"><table width="120" cellspacing="1" cellpadding="5">
	<tr><th class="h">��^����</th></tr>

</table></div>

<div id="blank" style="height:10px; clear:both"></div>
</div>	
';
}
function scrollBar($content){
	print'
	<marquee direction="left" scrolldelay="1" scrollamount="2" onmouseout="if(document.all!=null){this.start()}" onmouseover="if(document.all!=null){this.stop()}"><a href="notice.php?fid=-1#1">■■■ '.$content.' ■■■</a>
		</marquee>
		';
	}
function checkLogin(){
	$login = false;
	if(strlen(@$_SESSION['user'])==0){}else{
		$login = true;
	}
	return $login;
}
function getUserName(){
	$name = "Guest";
	if(strlen(@$_SESSION['user'])!=0){
		$name = $_SESSION['user'];
	}
	return $name;
}
function getTotalTopic(){
	$topic = 100;
	return $topic;	
}
function getTopic($category){
	// sum the topic by category
	return rand(50,999);
}
function getTotalMember(){
	$member = 50;
	return $member;	
}
function Login($UserName, $password){
 	$pw = file("pw.txt");
	$approve = false;
	if($UserName == trim($pw[0]) && $password == trim($pw[1])){
		$approve =  true;
	}
	return $approve;
}
function forumsCategories($header,$discribe,$category){
$pid = getLatestPid($category);
$author = getAuthor($pid);
$title = getTopicTitle($pid);
$time = getLatestReplay($pid);
return '
<tr class="tr3">
<th>
<a href="javaForum.php">'.$header.'</a><br>
<span class="smalltxt gray">'.$discribe.'</span>
</th>
<td></td>
<td class="tal y-style"><spax="f10">'.getTopic($category).'</span><br></td>
<th><a href="topic.php?pid="'.$pid.'"" class="a2">'.$title.'</a><br>
<span class="f12">'.$author.'</span>
<span class="f9 gray">[ '.$time.' ]</span> &nbsp;</th>
<td class="y-style" style="word-break: keep-all;word-wrap:no-wrap">'.getAdministrator($category).'</td>
</tr>	';	
}

function getLatestPid($category){
	$pid = rand(1,50);
	return $pid;
}
function getAuthor($pid){
	return "Author";	
}
function getTopicTitle($pid){
	return "Title";	
}
function getLatestReplay($pid){
	return "Time";	
}
function getAdministrator($category){
	return "lishi500";	
}
function WebEnd(){
print'
	</body>
	</html>
';
}
?>